﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Playground.Scratches
{
    class ObjectDesrtuctor
    {
        public int X;

        public ObjectDesrtuctor(int i)
        {
            X = i;
        }

        // called when object is recycled
        // gets called right before Garbage collection happens
        ~ObjectDesrtuctor()
        {
            Console.WriteLine("Destructing " + X);
        }

        // generates an object that is immediately destroyed
        public void Generator(int i)
        {
            var o = new ObjectDesrtuctor(i);
        }
    }
}
